package icu.sehnen.controller;


import icu.sehnen.common.CommonResult;
import icu.sehnen.model.CoachModel;
import icu.sehnen.service.CoachService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@CrossOrigin
@RequestMapping("/coach")
public class CoachController {
    @Autowired
    CoachService coachService;
        @RequestMapping("/list")
    public CommonResult findAll(){
      List<CoachModel> coachModelList=   coachService.findAll();
        return  CommonResult.success(coachModelList);
    }
    @PostMapping("/add")
    public  CommonResult add(CoachModel coachModel){
            coachService.add(coachModel);
            return  CommonResult.success();
    }
    @PostMapping("/update")
    public CommonResult update(CoachModel coachModel){
            coachService.update(coachModel);
            return  CommonResult.success();
    }
    @GetMapping("find/{id}")
    public CommonResult find(@PathVariable Long id){
            CoachModel coachModel=coachService.find(id);
            return  CommonResult.success(coachModel);
    }


}
